collectd uses a plugin mechanism to write collected monitoring data to different data storage software in various formats.
TDengine supports writing data from both the collectd write_tsdb plugin and collectd binary data.

The collectd write_tsdb plugin is an official collectd plugin that converts monitoring data into the OpenTSDB protocol format and sends it to backend storage systems.

#### Writing Data via collectd write_tsdb Plugin

##### Configuring taosAdapter

Method to configure taosAdapter to receive collectd write_tsdb plugin data:

- Enable the configuration item in the taosAdapter configuration file (default location is /etc/taos/taosadapter.toml)

    ```toml
    # Automatically create the database when writing data with the schemaless feature if set to true.
    smlAutoCreateDB = true
    [opentsdb_telnet]
    enable = true
    maxTCPConnections = 250
    tcpKeepAlive = false
    dbs = ["opentsdb_telnet", "collectd", "icinga2", "tcollector"]
    ports = [6046, 6047, 6048, 6049]
    user = "root"
    password = "taosdata"
    ```

    The default database name written by taosAdapter is `collectd`, but you can also modify the dbs item in the taosAdapter configuration file to specify a different name. Fill in user and password with the actual TDengine configuration values. After modifying the configuration file, taosAdapter needs to be restarted.

    The `smlAutoCreateDB` configuration item is used to enable the automatic database creation feature. When set to true, taosAdapter will automatically create the corresponding database upon receiving data if it does not already exist.

- You can also use taosAdapter command line parameters or set environment variables to start, to enable taosAdapter to receive collectd data, for more details please refer to the taosAdapter reference manual.

##### Configuring collectd

Modify the related configuration items in the collectd configuration file (default location /etc/collectd/collectd.conf).

```xml
LoadPlugin network
<Plugin network>
         Server "<taosAdapter's host>" "<port for collectd direct>"
</Plugin>
```

Where \<taosAdapter's host> should be filled with the domain name or IP address of the server running taosAdapter. \<port for collectd direct> should be filled with the port used by taosAdapter to receive collectd data (default is 6045).

Example as follows:

```xml
LoadPlugin network
<Plugin network>
         Server "127.0.0.1" "6045"
</Plugin>
```

#### Writing collectd Binary Protocol Data

##### Configuring taosAdapter

Method to configure taosAdapter to receive collectd binary data:

- Enable the configuration item in the taosAdapter configuration file (default location is /etc/taos/taosadapter.toml)

    ```toml
    ...
    [collectd]
    enable = true
    port = 6045
    db = "collectd"
    user = "root"
    password = "taosdata"
    worker = 10
    ...
    ```

    The default database name written by taosAdapter is `collectd`, but you can also modify the db item in the taosAdapter configuration file to specify a different name. Fill in user and password with the actual TDengine configuration values. After modifying the configuration file, taosAdapter needs to be restarted.

- You can also use taosAdapter command line parameters or set environment variables to start, to enable taosAdapter to receive collectd data, for more details please refer to the taosAdapter reference manual.

##### Configuring collectd

Modify the related configuration items in the collectd configuration file (default location /etc/collectd/collectd.conf).

```xml
LoadPlugin write_tsdb
<Plugin write_tsdb>
        <Node>
                Host "<taosAdapter's host>"
                Port "<port for collectd write_tsdb plugin>"
                ...
        </Node>
</Plugin>
```

Where \<taosAdapter's host> should be filled with the domain name or IP address of the server running taosAdapter. \<port for collectd write_tsdb plugin> should be filled with the port used by taosAdapter to receive collectd write_tsdb plugin data (default is 6047).

```xml
LoadPlugin write_tsdb
<Plugin write_tsdb>
        <Node>
                Host "127.0.0.1"
                Port "6047"
                HostTags "status=production"
                StoreRates false
                AlwaysAppendDS false
        </Node>
</Plugin>
```

Then restart collectd:

```shell
systemctl restart collectd
```
